/**
  ******************************************************************************
  * @author     Chris
  * @since      2024/6/14 22:34
  *
  * @file       hd_led.h
  * @brief      Head file of LED Hardware Driver.
  *
  * @note       This file contains the hardware driver's function declaration
  *             for the LED.
  *
  * @warning    None.
  ******************************************************************************
  * Change Logs:
  *   Date           Author       Notes
  *   2024/6/14      Chris        the first version
  *
  ******************************************************************************
  */

#ifndef JXTECH_LED_H
#define JXTECH_LED_H

#include "pd_gpio.h"


struct LEDVtbl;

// Object properties
typedef struct {
    struct LEDVtbl* vptr;
    GPIO* gpio;
} LED;

// Object virtual table
struct LEDVtbl {
    void (*init)(const LED* this);

    void (*on)(const LED* this);

    void (*off)(const LED* this);

    void (*toggle)(const LED* this);
};

// Object constructor and member function
void LED_constructor(LED* this, GPIO* gpio);

static inline void LED_init(const LED* this) {
    this->vptr->init(this);
}

static inline void LED_on(const LED* this) {
    this->vptr->on(this);
}

static inline void LED_off(const LED* this) {
    this->vptr->off(this);
}

static inline void LED_toggle(const LED* this) {
    this->vptr->toggle(this);
}

#endif
